package personresources.manager.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;

import personresources.manager.dao.GroupDao;
import personresources.manager.hibernate.Group;
@Repository("groupDao")
public class GroupDaoImpl extends GenericDaoImpl<Group, Integer> implements GroupDao {
	
	public GroupDaoImpl() {
		super(Group.class);
	
	}
	@SuppressWarnings("unchecked")
	public List<Group> getGroups() {
		HibernateCallback action = new HibernateCallback() {
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				
				StringBuffer sqlCommand = new StringBuffer(" FROM Group");
				
				return session.createQuery(sqlCommand.toString()).list();
			}
		};
		
		return (List<Group>) getHibernateTemplate().execute(action);
	}
}
